/*
 * @Author: funlee
 * @Email: i@funlee.cn
 * @Date: 2018-10-30 00:09:03
 * @Description: 实时处置率
 */
define(function () {

  var RightTop = {
    render: function (data) {
      var czsl = data.czsl;
      var gjsl = data.gjsl;

      var rate = parseInt(czsl * 100 / gjsl, 10);
      
      var myChart = echarts.init(document.getElementById('pieChart'));

      var placeHolderStyle = {
        normal: {
          label: {
            show: false
          },
          labelLine: {
            show: false
          },
          color: "rgba(0,0,0,0)",
          borderWidth: 0
        },
        emphasis: {
          color: "rgba(0,0,0,0)",
          borderWidth: 0
        }
      };

      var outerRadius = ['60%', '72%']
      var innerRadius = ['58%', '72%'];

      var centerLeft = ['24%', '50%'];
      var centerRight = ['76%', '50%'];
      
      var startAngle = 225;

      var option = {
        title: [{
          text: '告警数量',
          left: '23%',
          top: '60%',
          textAlign: 'center',
          textStyle: {
            fontWeight: 'normal',
            fontSize: '16',
            color: '#74E5FF',
            textAlign: 'center',
          },
        }, {
          text: '处置数量',
          left: '75%',
          top: '60%',
          textAlign: 'center',
          textStyle: {
            color: '#74E5FF',
            fontWeight: 'normal',
            fontSize: '16',
            textAlign: 'center',
          },
        }],
        series: [
          //外圈的边框
          {
            type: 'pie',
            hoverAnimation: false, //鼠标经过的特效
            radius: outerRadius,
            center: centerLeft,
            startAngle,
            labelLine: {
              normal: {
                show: false
              }
            },
            label: {
              normal: {
                position: 'center'
              }
            },
            data: [{
              value: 75,
              itemStyle: {
                normal: {
                  color: '#094470',
                }
              },
            }, {
              value: 25,
              itemStyle: placeHolderStyle,
            }]
          },
          {
            type: 'pie',
            hoverAnimation: false,
            radius: outerRadius,
            center: centerRight,
            startAngle,
            labelLine: {
              normal: {
                show: false
              }
            },
            label: {
              normal: {
                position: 'center'
              }
            },
            data: [{
                value: 75,
                itemStyle: {
                  normal: {
                    color: '#094470',
                  }
                },
              }, {
                value: 25,
                itemStyle: placeHolderStyle,
              },

            ]
          },
          { // 告警数量
            type: 'pie',
            hoverAnimation: false, //鼠标经过的特效
            radius: innerRadius,
            center: centerLeft,
            startAngle,
            labelLine: {
              normal: {
                show: false
              }
            },
            label: {
              normal: {
                position: 'center'
              }
            },
            data: [{
                value: 75,
                itemStyle: {
                  normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                      offset: 0,
                      color: '#e9a234'
                    }, {
                      offset: 1,
                      color: '#4efcfa'
                    }]),
                  }
                },
                label: {
                  normal: {
                    formatter: function(){ return gjsl},
                    position: 'center',
                    show: true,
                    textStyle: {
                      fontSize: '38',
                      fontWeight: 'normal',
                      fontFamily: 'DS-DigitalItalic',
                      color: '#fee300',
                    }
                  }
                },
              }, {
                value: 25,
                itemStyle: placeHolderStyle,
              },

            ]
          },
          { // 处置数量
            type: 'pie',
            hoverAnimation: false,
            radius: innerRadius,
            center: centerRight,
            startAngle,
            labelLine: {
              normal: {
                show: false
              }
            },
            label: {
              normal: {
                position: 'center'
              }
            },
            data: [{
                value: rate,
                itemStyle: {
                  normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                      offset: 0,
                      color: '#e9a234'
                    }, {
                      offset: 1,
                      color: '#4efcfa'
                    }]),
                  }
                },
                label: {
                  normal: {
                    formatter: function() {return czsl},
                    position: 'center',
                    show: true,
                    textStyle: {
                      fontSize: '38',
                      fontWeight: 'normal',
                      fontFamily: 'DS-DigitalItalic',
                      color: '#fee300',
                    }
                  }
                },
              }, {
                value: 100 - rate,
                itemStyle: placeHolderStyle,
              },

            ]
          }
        ]
      };
      
      myChart.setOption(option)
      
      $('.right-top .rate').find('span').html(rate);
     
    }
  }
  return RightTop
})

